package pers.xiaojun.boot.module.system.dao.mapper.dict;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import org.apache.ibatis.annotations.Mapper;
import pers.xiaojun.boot.module.system.dao.entity.dict.DictTypeDO;

/**
 * 字典类型数据访问层
 *
 * @author xiaojun
 * @since 2025-11-05
 */
@Mapper
public interface DictTypeMapper extends BaseMapper<DictTypeDO> {


    /**
     * 根据字典类型名称获取字典
     *
     * @param name 字典类型名称
     * @return 字典
     */
    default DictTypeDO selectByName(String name) {
        return selectOne(new LambdaQueryWrapper<DictTypeDO>()
                .eq(DictTypeDO::getName, name)
        );
    }

    /**
     * 根据字典类型获取字典
     *
     * @param type 字典类型
     * @return 字典
     */
    default DictTypeDO selectByType(String type) {
        return selectOne(new LambdaQueryWrapper<DictTypeDO>()
                .eq(DictTypeDO::getType, type)
        );
    }
}